<?php
class UploadComponent extends Object {
	var $components = array ('Resize');
	
	function startup(&$controller) {
		// This method takes a reference to the controller which is loading it.
	    // Perform controller initialization here.
	}
	
	function upload(&$file, $dir, $rename = true) {
		$return = false;
		// current time in miliseconds 
		$time = microtime ( 1 ) * 1000;
		if ($rename)
		{		
			$file['name']=md5($time).$file['name'];
		}
		//debug($dir);
		//debug($file);
		if(@move_uploaded_file($file['tmp_name'],$dir.$file['name']))
		{		     
			$return = true;	
		}
		/*if($return)
		{
			echo "da up anh len";
		}*/
		return $return;
	}
}
?>